package 回溯;

import java.util.LinkedList;
import java.util.List;

public class _78_子集 {

    private List<List<Integer>> res = new LinkedList<>();

    public List<List<Integer>> subsets(int[] nums) {
        List<Integer> temp = new LinkedList<>();
        backtrack(temp,nums,0);
        return res;
    }

    private void backtrack(List<Integer> temp, int[] nums, int level) {
        res.add(new LinkedList<>(temp));

        for (int i = level; i < nums.length; i++) {
            temp.add(nums[i]);
            backtrack(temp,nums,i + 1);
            temp.remove(temp.size() - 1);
        }
    }
}
